<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${projectName}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src='<c:url value="/js/boot.js"></c:url>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>' />
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: "微软雅黑";
}

#detailPan {
	width: 100%;
	height: 100%;
}

p {
	margin-left: 5px;
	font-size: 14px;
}

body {
	height: 100%;
	overflow: hidden;
}

.filterPan td {
	padding: 0;
}

.level1Class {
	margin-left: 10px;
}

.level2Class {
	margin-left: 30px;
}

.level3Class {
	margin-left: 50px;
}

.deepDark {
	background-color: #CCC488;
}

.normalDark {
	background-color: #FFF7BB;
}

.lowDark {
	
}

.mini-splitter-pane {
	overflow: auto;
}

.mini-panel-body {
	padding: 0;
}

html body .searchbox .mini-buttonedit-icon {
	background: url('<c:url value="/share/img/magnifier-zoom.png"></c:url>')
		no-repeat 5% 5%;
}

.nameTitle {
	color: red;
}
</style>
<script type="text/javascript">
	var sexData = [ {
		id : 1,
		text : "男"
	}, {
		id : 0,
		text : "女"
	} ];
	var typeData = [ {
		id : 9,
		text : "超级管理员"
	}, {
		id : 8,
		text : "公司管理员"
	} ];
</script>

</head>
<body>
	<div class="mini-toolbar"
		style="padding: 0px; border-width: 1px; border-bottom-width: 0px;">
		<table style="width: 100%;">
			<tr>
				<td style="width: 5px; height: 23px;"></td>
				<td><a class="mini-button" id="addBtn" iconCls="icon-add"
					plain="true" onclick="add()">添加公告</a>
					<a class="mini-button" id="deleteBtn" iconCls="icon-remove"
					plain="true" onclick="_delete">删除</a></td>
			</tr>
		</table>
	</div>
	<div class="mini-fit">
		<div id="datagrid1" class="mini-datagrid gridFull"
			borderStyle="border:1;" showReloadButton="true" pagesize="100"
			sizeList="[20,50,100,200]" allowCellWrap="true"
			allowHeaderWrap="true" idField="No" multiSelect="true"
			showPager="true" allowAlternating="true"
			ondrawcell="ondatagridDrawCell" onrowdblclick=""
			style="height: 100%; width: 100%; -moz-user-select: none; -webkit-user-select: none;"
			collapseGroupOnLoad="false" showColumnsMenu="true"
			showFilterRow="true" onshowrowdetail="onShowRowDetail">
			<div property="columns">
				<div type="indexcolumn" width="40px"></div>
				<div type="checkcolumn" width="70px" align="center">
					<a class="mini-button" property="filter" id="removeBtn"
						iconCls="icon-broom" tooltip="清除筛选" onclick="removeSearch">清除
					</a>
				</div>
				<div field="Title" width="200px" headerAlign="center" align="left"
					allowSort="true">
					公告主题<input id="filter1" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="Salutation" width="160px" headerAlign="center" align="left"
					allowSort="true">
					称谓<input id="filter2" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="Inscribe" width="160px" headerAlign="center" align="center"
					allowSort="true">
					发告单位<input id="filter4" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="NoticeTime" width="100px" headerAlign="center"
					align="center" allowSort="true">
					公告日期<input id="filter5" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="Content" width="100%" headerAlign="center" align="left"
					allowSort="true">
					公告内容<input id="filter3" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<!-- <div name="emptyCol" width='100%' headerAlign="center"
					align="center" cellStyle="padding:0;"></div> -->
			</div>
		</div>
	</div>

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var isKeepStat3 = false;

		var rootPath = '${rootPath}';

		var filterHelper = gridFilter();

		var datagrid1 = mini.get("datagrid1");
		var filter1 = mini.get("filter1");
		var filter2 = mini.get("filter2");
		var filter3 = mini.get("filter3");
		var filter4 = mini.get("filter4");
		var filter5 = mini.get("filter5");

		$(function() {
			loadGrid1();
		});
		function onselect() {
			var filterValue1 = filter1.getValue();
			var filterValue2 = filter2.getValue();
			var filterValue3 = filter3.getValue();
			var filterValue4 = filter4.getValue();
			var filterValue5 = filter5.getValue();
			if (filterValue1 != "") {
				var filterdata = filterHelper.formFilterData("Title",
						filterValue1, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue2 != "") {
				var filterdata = filterHelper.formFilterData("Salutation",
						filterValue2, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue3 != "") {
				var filterdata = filterHelper.formFilterData("Content",
						filterValue3, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue4 != "") {
				var filterdata = filterHelper.formFilterData("Inscribe",
						filterValue4, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue5 != "") {
				var filterdata = filterHelper.formFilterData("NoticeTime",
						filterValue5, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			loadGrid1();
		}
		function removeSearch() {
			filter1.setText();
			filter1.setValue();
			filter2.setValue();
			filter2.setText();
			filter3.setValue();
			filter3.setText();
			filter4.setValue();
			filter4.setText();
			filter5.setValue();
			filter5.setText();
			filterHelper.clearFilterData();
			loadGrid1();
		}
		function loadGrid1() {
			var filterData = filterHelper.getFilterData();
			var postData = new Object();
			if (filterData != null || filterData.length > 0) {
				postData.filterdata = mini.encode(filterData);
			}
			var url = "<c:url value='/notice/list' />";
			datagrid1.load(url);
			datagrid1.load(postData);
		}
		function ondatagridDrawCell(e) {
			var row = e.row;
			var field = e.field;
			/* if (field == "Action") {
				var id = row.Id;
				e.cellHtml = '<a class="aTagUnderLine" href="javascript:update('
						+ id + ')">[查看]</a>';
			} */
		}
		function reloadList() {
			datagrid1.reload();
		}

		function add() {
			var titleName = "新增公告"
			var url = "<c:url value='/notice/add' />";
			mini.open({
				url : url,
				title : titleName,
				width : 800,
				height : 640,
				onload : function() {
					/* var iframe = this.getIFrameEl();
					var data = {
					}; */
					//iframe.contentWindow.SetData(data);
				},
				ondestroy : function(action) {
					if (action == 'ok') {
						reloadList();
					}
				}
			});
		}
		function _delete() {
			var rows = datagrid1.getSelecteds();
			if (rows.length < 1) {
				mini.alert('请选择要删除的公告！');
				return;
			}
			mini.confirm("确定删除所选择公告？", "确定？", function(action) {
				if (action == "ok") {
					var id = "";
					for (var i = 0; i < rows.length; i++) {
						if (id == "") {
							id = rows[i].Id;
						} else {
							id += "," + rows[i].Id;
						}
					}
					var url = rootPath + "/notice/delete";
					$.ajax({
						url : url,
						method : "post",
						dataType : "json",
						data : {
							"ids" : id
						},
						success : function(data) {
							if (data) {
								top.commonTools.showTip("操作成功！", 1);
								reloadList();
							} else {
								top.commonTools.showTip("操作失败！", 2);
								reloadList();
							}
						},
						error : function() {
							top.commonTools.showTip("操作发生错误！", 2);
						}

					});
				}
			});
		}
		function edit() {
			var rows = datagrid1.getSelecteds();
			if (rows.length < 1) {
				mini.alert('请选择要修改的属性！');
				return;
			} else if (rows.length > 1) {
				mini.alert('只能选择一条数据！');
				return;
			}
			update(rows[0].Id);
		}
		function update(id) {
			var url = "<c:url value='/config/user/update/' />" + id;
			mini.open({
				url : url,
				title : "修改员工属性",
				width : 400,
				height : 300,
				onload : function() {
				},
				ondestroy : function(action) {
					if (action == 'ok') {
						reloadList();
					}
				}
			});
		}
	</script>
</body>
</html>